;; using a trie, tries to produce a word made out of given letters

(define (anagrams t letters acc)
  (if (null? letters)
      (list (reverse acc))
      (select letters '()
	      (lambda (letter rest)
		(let ((t^ (lookup-trie t (list letter))))
		  (if t^
		      (anagrams t^ rest (cons letter acc))
		      '()))))))
